package com.ruoyi.web.controller.ring.app;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.ring.domain.RingBloodOxygenDetail;
import com.ruoyi.ring.service.IRingBloodOxygenDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 血氧详情 （APP）
 */
@Slf4j
@RestController
@RequestMapping("/ring/app/ring_blood_oxygen_detail")
public class AppBloodOxygenDetailController extends BaseController
{
    @Resource
    private IRingBloodOxygenDetailService ringBloodOxygenDetailService;

    /**
     * 血氧详情上报-app
     */
    @Log(title = "血氧详情", businessType = BusinessType.INSERT)
    @PostMapping("/add-blood-oxygen-detail")
    public AjaxResult addBloodOxygenDetail(@RequestBody RingBloodOxygenDetail ringBloodOxygenDetail) {
        long userId = SecurityUtils.getUserId();
        log.info("血氧详情addBloodOxygenDetail: userId={}, param={}", userId, JSON.toJSONString(ringBloodOxygenDetail));
        ringBloodOxygenDetail.setDailyValue(new Date());
        return toAjax(ringBloodOxygenDetailService.insertRingBloodOxygenDetail(ringBloodOxygenDetail));
    }
}
